package com.list.data.structure;

import com.hp.hpl.jena.rdf.model.Property;
import com.hp.hpl.jena.rdf.model.Resource;

public class Path {
	private Resource domain;
	private Resource range;
	private Property property;
	private boolean direction;
	private double weight;
	
	public Path(Resource domain, Resource range, Property property, double weight,
			boolean direction) {
		super();
		this.domain = domain;
		this.range = range;
		this.property = property;
		this.weight = weight;
		this.direction = direction;
	}
	
	public Resource getDomain() {
		return direction ? this.domain : this.range;
	}
	public void setDomain(Resource domain) {
		this.domain = domain;
	}
	public Resource getRange() {
		return direction? this.range : this.domain;
	}
	public void setRange(Resource range) {
		this.range = range;
	}
	public Property getProperty() {
		return property;
	}
	public void setProperty(Property property) {
		this.property = property;
	}
	public boolean getDirection() {
		return direction;
	}
	public void setDirection(boolean direction) {
		this.direction = direction;
	}
	
    public double getWeight() {
		return weight;
	}

	public void setWeight(double weight) {
		this.weight = weight;
	}

	@Override
    public String toString(){
        StringBuffer sb = new StringBuffer();
        
        try{
            sb.append(this.getDomain().getLocalName());
            if(this.getDirection()){
                sb.append(" --> ");                
            }else{
                sb.append(" <-- ");
            }
            sb.append(this.getProperty().getLocalName());    
            if(this.getDirection()){
                sb.append(" --> ");                
            }else{
                sb.append(" <-- ");
            }
            sb.append(this.getRange().getLocalName());
            sb.append("  W = ");
            sb.append(this.getWeight());
            sb.append("\n");
        }catch(NullPointerException e){
            sb.append(this.getDomain().getLocalName());
            sb.append(" --> ");    
            sb.append(this.getRange().getLocalName());
        }
        
        return sb.toString();
    }
	
	
}
